<template>
	<view>
		<s-pull-scroll ref="pullScroll" :pullDown="pullDown" :pullUp="loadData" :back-top="true">
			<view class="list">
				<view class="item items-center justify-between" v-for="item in dataList" :key="item.id">
					<view class="left">
						<view class="price">
							{{item.sum}}元
						</view>
						<view class="time">
							{{item.createDate}}
						</view>
					</view>
					<view class="right">
						{{item.status == '0' ? '审核中' : item.status == '1' ? '已开票' : '开票失败'}}
					</view>
				</view>
			</view>
		</s-pull-scroll>
		<mix-loading v-if="isLoading"></mix-loading>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				dataList:[]
			};
		},
		onLoad() {
			this.refresh();
		},
		methods:{
			pullDown(pullScroll) {
				setTimeout(() => {
					this.loadData(pullScroll);
				}, 200);
			},
			async loadData(pullScroll) {
				const data = {
					uid: uni.getStorageSync('uid'),
					pageNo: pullScroll.page,
					pageSize: '10'
				};
				if (pullScroll.page == 1) this.dataList = [];
				const res = await this.$request('user/invoice-history', data, { showLoading: true });
				if (res.result == 0) {
					this.dataList = this.dataList.concat(res.data.list);
					pullScroll.endByPage(Math.ceil(res.data.count / 10), res.data.list);
				} else {
					this.$util.msg(res.resultNote);
				}
			}
		},
	}
</script>

<style lang="scss" scoped> 
	.list{
		padding: 30rpx;
		.item{
			padding: 20rpx 50rpx;
			background: #FFFFFF;
			border-radius: 20rpx;
			margin-bottom: 20rpx;
			.left{
				width: 80%;
				.price{
					font-size: 32rpx;
					font-family: PingFang SC;
					font-weight: bold;
					color: #333333;
				}
				.time{
					font-size: 22rpx;
					font-family: PingFang SC;
					color: #999999;
					margin-top: 10rpx;
				}
			}
			.right{
				font-size: 28rpx;
				font-family: PingFang SC;
				font-weight: bold;
				color: #5A954D;
			}
			.text-1{
				color: #5D81BE;
			}
			.text-2{
				color: #FD4E3C;
			}
		}
	}
</style>
